let vm = new Vue({
    el: ".printWarehouseTotal",
    data: {
        tableData: [],
        allpages: 0,
        tbLoading: true,
    },
    methods: {
        getDate() {
            let par = {
                // code: leiku.GetUrlParam("code"),
                // name: leiku.GetUrlParam("name"),
                // pg: leiku.GetUrlParam("pg"),
                // cangku: leiku.GetUrlParam("cangku"),
                // khid : leiku.GetUrlParam("khid "),
                // cangwei: leiku.GetUrlParam("cangwei"),
                // benwaicangku: leiku.GetUrlParam("benwaicangku"),
                // neibupici: leiku.GetUrlParam("neibupici"),
            }

            leiku.post('http://dongtai.fsslpc.com/api/2020102180885116', par, res => {
                let data = res.data;
                console.log(data)
                if (data.a.length) {
                    this.tableData = data;
                }
                // console.log(data.a.length)
                this.tbLoading = false
                this.printPageing();
            })
        },
        printPageing() {
            const _this = this;
            const printHeight = 1200;
            

            let headHeight = $("thead").outerHeight()

            let pages = 1;

            _this.$nextTick(() => {
                let contentHeight = 0;

                $(".tdStyle").each(function() {
                    // console.log(this)
                    contentHeight += $(this).outerHeight();
                    if (headHeight + contentHeight >= printHeight) {
                        const newNode = document.createElement("div");
                        newNode.setAttribute('class', 'cut');
                        this.parentNode.insertBefore(newNode, this)
                        pages++;
                        contentHeight = 0;
                    }
                    // console.log(this.parentNode)
                })
                this.allpages = pages
                // console.log(this)
            })
            // console.log($("#tdcontent")[0])
        },
        prints() {
            $(this.$refs.printPage).print({
                stylesheet: "../css/printWarehouseTotal.css",
                globalStyles: false,
                mediaPrint: true,
                iframe: true,
            });
 
        }
    },
    mounted() {
        this.getDate();
        
    }
})